package com.test.gpa.test.suanfa;

import com.test.gpa.test.Person;

import java.util.concurrent.Callable;

public class able {
    public static void main(String[] args) {
        FirstTread firstTread = new FirstTread(new Person("Tom", 8900, 23, "male", "New York"));
        firstTread.start();
        RunThread runThread = new RunThread();
        new Thread( runThread).start();
        CallThread callThread = new CallThread(new Person("Tom", 8900, 23, "male", "New York"), "newName");

       try {

           System.out.println("callThread call= " + callThread.call().getName());
       }catch (Exception e){
           e.printStackTrace();
           throw new RuntimeException();
       }


    }
}

class FirstTread extends Thread {
    public Person person;

    public FirstTread(Person person) {
        this.person = person;
    }

    @Override
    public void run() {
        System.out.println("run方法:"+person.getName());
    }
}
class RunThread implements Runnable{

    @Override
    public void run() {
        System.out.println("RunThread方法正在执行:"+Thread.currentThread().getName());
    }
}
class CallThread implements Callable{


    private Person person;
    private String name;

    public CallThread(Person person, String name) {
        this.person = person;
        this.name = name;
    }

    @Override
    public Person call() throws Exception {
          person.setName(name);
          return person;
    }
}
